//
//  PPFoundTableViewCell.m
//  pickpic
//
//  Created by Jinxiao on 8/27/16.
//  Copyright © 2016 MicroDream. All rights reserved.
//

#import "PPProfileTableViewFlowCell.h"

@interface PPProfileTableViewFlowCell ()
@property (strong, nonatomic) IBOutlet UIImageView *leftImageView;
@property (strong, nonatomic) IBOutlet UIImageView *middleImageView;
@property (strong, nonatomic) IBOutlet UIImageView *rightImageView;
@end

@implementation PPProfileTableViewFlowCell

- (void)layoutSubviews {
    [super layoutSubviews];

    self.backgroundColor = [UIColor clearColor];
}

- (void)setLeftAlbum:(PPAlbumObject *)leftAlbum {
    _leftAlbum = leftAlbum;

    if(leftAlbum != nil) {
        _leftImageView.hidden = NO;

        [leftAlbum.existingCoverURLString applyToImageView:_leftImageView];

        __weak typeof(self) weakSelf = self;
        [_leftImageView setActionBlock:^(UIControl *control) {
            [weakSelf.delegate flowCell:weakSelf didSelectAlbum:leftAlbum];
        } forEvent:UIControlEventTouchUpInside];
    } else {
        _leftImageView.hidden = YES;
        [_leftImageView setActionBlock:nil forEvent:UIControlEventTouchUpInside];
    }
}

- (void)setMiddleAlbum:(PPAlbumObject *)middleAlbum {
    _middleAlbum = middleAlbum;

    if(middleAlbum != nil) {
        _middleImageView.hidden = NO;

        [middleAlbum.existingCoverURLString applyToImageView:_middleImageView];

        __weak typeof(self) weakSelf = self;
        [_middleImageView setActionBlock:^(UIControl *control) {
            [weakSelf.delegate flowCell:weakSelf didSelectAlbum:middleAlbum];
        } forEvent:UIControlEventTouchUpInside];
    } else {
        _middleImageView.hidden = YES;
        [_middleImageView setActionBlock:nil forEvent:UIControlEventTouchUpInside];
    }
}

- (void)setRightAlbum:(PPAlbumObject *)rightAlbum {
    _rightAlbum = rightAlbum;

    if(rightAlbum != nil) {
        _rightImageView.hidden = NO;

        [rightAlbum.existingCoverURLString applyToImageView:_rightImageView];

        __weak typeof(self) weakSelf = self;
        [_rightImageView setActionBlock:^(UIControl *control) {
            [weakSelf.delegate flowCell:weakSelf didSelectAlbum:rightAlbum];
        } forEvent:UIControlEventTouchUpInside];
    } else {
        _rightImageView.hidden = YES;
        [_rightImageView setActionBlock:nil forEvent:UIControlEventTouchUpInside];
    }
}

@end
